package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.feign.WxMiniRedeemCardClient;
import com.sc.nft.req.redeemcard.RedeemCardPageReq;
import com.sc.nft.req.redeemcard.RedeemCardReq;
import com.sc.nft.req.redeemcard.RedeemCardRuleReq;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.redeemcard.RedeemCardDetailsVO;
import com.sc.nft.vo.redeemcard.RedeemCardPageVO;
import com.sc.nft.vo.redeemcard.RedeemCardWebDetailsVO;
import com.sc.nft.vo.redeemcard.RedeemCardWebPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/redeemCard")
@Api(tags = "小程序兑换卡")
public class WxMiniRedeemCardController {

    private final WxMiniRedeemCardClient wxMiniRedeemCardClient;

    /**
     * 小程序兑换卡创建
     * @param request
     * @return
     */
    @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "创建兑换卡")
    @SysMemberLogin
    public Result createHome(@Valid @RequestBody RedeemCardReq request) {
        return wxMiniRedeemCardClient.create(request);
    }

    /**
     * 小程序兑换卡编辑
     * @param request
     * @return
     */
    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "编辑兑换卡")
    @SysMemberLogin
    public Result updateHome(@Valid @RequestBody RedeemCardReq request) {
        return wxMiniRedeemCardClient.update(request);
    }


    /**
     * 上架兑换卡
     * @param request
     * @return
     */
    @PostMapping(value = "/enable", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "上架兑换卡")
    @SysMemberLogin
    public Result enable(@RequestBody IdRequest request) {
        return wxMiniRedeemCardClient.enable(request);
    }

    /**
     * 下架兑换卡
     * @param request
     * @return
     */
    @PostMapping(value = "/disable", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "下架兑换卡")
    @SysMemberLogin
    public Result disable(@RequestBody IdRequest request) {
        return wxMiniRedeemCardClient.disable(request);
    }


    /**
     * 删除兑换卡
     * @param request
     * @return
     */
    @PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除兑换卡")
    @SysMemberLogin
    public Result remove(@RequestBody IdRequest request) {
        return wxMiniRedeemCardClient.remove(request);
    }

    /**
     * 小程序兑换卡详情
     * @param request
     * @return
     */
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "详情兑换卡")
    @SysMemberLogin
    public Result<RedeemCardDetailsVO> homeDetails(@RequestBody IdRequest request) {
        return Result.success(wxMiniRedeemCardClient.homeDetails(request));
    }


    /**
     * 小程序兑换卡列表
     * @param request
     * @return
     */
    @PostMapping(value = "/adminPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "兑换卡列表")
    @SysMemberLogin
    public PageResult<RedeemCardPageVO> adminPage(@RequestBody RedeemCardPageReq request) {
        return wxMiniRedeemCardClient.adminPage(request);
    }



    /**
     * 兑换卡使用规则保存
     * @param request
     * @return
     */
    @PostMapping(value = "/ruleSave", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "兑换卡使用规则保存")
    @SysMemberLogin
    public Result ruleSave(@RequestBody RedeemCardRuleReq request) {
        return wxMiniRedeemCardClient.ruleSave(request);

    }


    /**
     * 兑换卡使用规则查询
     * @return
     */
    @PostMapping(value = "/ruleGet", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "兑换卡使用规则查看")
    public Result<String> ruleGet() {
        return wxMiniRedeemCardClient.ruleGet();
    }


}